import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'CountState.dart';
import 'ReduxTwo.dart';

class ReduxOne extends StatefulWidget {
  @override
  _ReduxOneState createState() => _ReduxOneState();
}

class _ReduxOneState extends State<ReduxOne> {
  @override
  Widget build(BuildContext context) {
    return StoreConnector<CountState, int>(
      converter: (store) => store.state.count,
      builder: (context, count) {
        return Scaffold(
          appBar: AppBar(
            title: Text("Redux测试首页"),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              Navigator.push(
                  context, MaterialPageRoute(builder: (context) => ReduxTwo()));
            },
            child: Icon(Icons.airplanemode_active),
            tooltip: "下一页",
          ),
          body: Center(
            child: Text(
              count.toString(),
              style: TextStyle(fontSize: 26, color: Colors.orange[500]),
            ),
          ),
        );
      },
    );
  }
}
